<%@ page language="java"
         contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"
         import="com.shxt.hotel.background.Consume"
         import="com.shxt.hotel.background.User"
         import="java.util.Map"
%>
<%
    request.setCharacterEncoding("UTF-8");
    String objJSON = request.getParameter("objJSON");
    
    if(session.getAttribute("id") == null){
        response.sendRedirect("../login.jsp");
    }else{
    	User user = new User();
        Map<String, Object> currentUser = user.getUserInfo((int)session.getAttribute("id"));
    
        Consume consume = new Consume();
        Map<String, Object> userPerm = user.getPermission((int)currentUser.get("user_permission"));
        
        int discount = (int)userPerm.get("consume_discount");
        int row = consume.userConsumeJSON(objJSON, (int)session.getAttribute("id"), discount);
        response.getWriter().write("ok");
    }
%>